package org.stone.project.redis.utils;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.stone.project.redis.prop.CustomRedisProp;

@Component
public class RedisUtil implements ApplicationContextAware {
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        redisTemplate = applicationContext.getBean(RedisTemplate.class);
        customRedisProp = applicationContext.getBean(CustomRedisProp.class);
    }

    private static RedisTemplate redisTemplate;

    private static CustomRedisProp customRedisProp;

    public static  <T> T getValue(String key){
        return (T)(redisTemplate.opsForValue().get(key));
    }

    public static  <T> void setValue(String key,T value){
        redisTemplate.opsForValue().set(key,value);
    }

    public String get() {
        return null;
    }
}
